package utils;

import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;

public class NumberUtils {

    public static void swap(int[] array, int i, int j) {
        if (i == j) {
            return;
        }
        array[i] += array[j];
        array[j] = array[i] - array[j];
        array[i] = array[i] - array[j];
    }

    public static <T> void swap(@NotNull ArrayList<T> list, int i, int j) {
        if (i == j) {
            return;
        }
        T temp = list.get(i);
        list.set(i, list.get(j));
        list.set(j, temp);
    }
}
